<?php
namespace Admin\Controller;
use Think\Controller;
class SkillTypeController extends Controller{
    public function index(){
        $this->display();
    }
    public function SkillTypeAdd(){
    	 $a = I('st_name');
    	$mod = new \Think\Model("skill_type");
        /*var_dump($_POST);
        die();*/
    	// ->where('st_fid=0')
     $list = M('skill_type')->select();
      
       if($a != null){
        // $_POST['st_id'] = I['st_name'];
         $asd['st_fid'] = I('pid');
        $asd['st_name'] = I('st_name');
        $asd['st_status'] = I('st_status');
        // var_dump($asd);
        // die();
    
	        $mod->create();     //用于将表单传递过来的数据打包
	       	$re = $mod->add($asd);
	        if($re){
	            $this->success("添加成功", "");
	        }else{
	            $this->error("添加失败","");
	        }
        }else{
			$data = array();
            foreach($list as $k => $v){
                if($v['st_fid'] == 0){
                    $data[]=$v;
                    foreach($list as $k1 => $v1){
                        if($v['st_id'] == $v1['st_fid']){
                            $v1['st_name'] = '---'.$v1['st_name'];
                            $data[] = $v1;
                            foreach ($list as $key => $value) {
                                if($v1['st_id'] == $value['st_fid']){
                                    $value['st_name'] = '------'.$value['st_name'];
                                    $data[]=$value;
                                }
                            }
                        }
                    }
                }
            }

// var_dump($data);
         // $this->assign ( "info", $info);
            $this->assign ( "data", $data);

               $this->display();
        	
        }

    	
    }
    
    public function SkillTypeList(){
    	$type=M('skill_type');
		$count=$type->count();
    	$typelist=$type->select();
        $this->assign('typelist',$typelist);
    	// var_dump($typelist);
        $this->display();
    }
   
}